 <{extends file="<{$tempdir}>/public/wxsite.html"}>  
<{block name=extendcss}> 
<link rel="stylesheet"  href="<{$siteurl}>/templates/<{$tempdir}>/public/wxsite/css/public.css">   
 <link rel="stylesheet"  href="<{$siteurl}>/templates/<{$tempdir}>/public/wxsite/css/shoplist.css">   
 <style>
 .clkitm { min-height: 80px;}
 </style>
<{/block}>
 <{block name=extendjs}> 
 <script src="<{$siteurl}>/templates/<{$tempdir}>/public/wxsite/js/template.min.js"></script>     
 <script>
var can_show = true;
var page = 1;
var catid = <{$typeid|default:0}>;
var order = 0;
var qsjid = 0;
var typeid = <{$typeid|default:0}>;
var myaddress = '<{$myaddress}>';
var search_input = '<{$search_input}>';
var shopshowtype  = '<{$shopshowtype}>';
$(function(){ 
shopdata();

	if( typeid != '' ){
		$('.kwselected').html( $(".typeid_"+typeid).attr('catename') );
		
  
			 $(".typeid_"+typeid).addClass('xz').siblings().removeClass('xz');
		   $('#toolbar').find('.se').removeClass('se');
		   $('#toolbar').find('.sh').removeClass('sh');
		   $('#supplierlist').html('');
		
		   $('#toolbar').find('li').eq(0).html('<a>'+ $(".typeid_"+typeid).text()+'<b class=""></b></a>');
		   catid = $(".typeid_"+typeid).attr('id');//alert(this).
		   can_show = true; 
		   page = 1;
		   
		   $(".kouweidiv").hide();
		   
		 
	}
	

	 
 		$('#toolbar .sele>li').bind("click", function() {   
	    $('#toolbar .sele>b').removeClass('se');
     $(this).addClass('se').siblings().removeClass('se');
     $(this).find('b').addClass('se');
      $('#toolbar .sub').addClass('sh');
       var cc = $('#toolbar .sele').find('li').index(this); 
       $('#toolbar .lizd').eq(cc).show().siblings().hide();//('sh'); 
   
      });
 });
function shopdata(){ 
	   $('#loading').show();
 	   $(".mBxCr").show(); 
 	   var url = siteurl+'/index.php?ctrl=wxsite&action=shophuilistdata&areaid=<{$areaid}>&datatype=json&random=@random@';  
 	    $.ajax({ 
      dataType: "json", 
      data:{page:page,search_input:search_input,order:order,catid:catid,qsjid:qsjid}, 
       url: url.replace('@random@', 1+Math.round(Math.random()*1000)),  
       success: function(content) {    
       	 if(content.error == false) 
      	{ 

      		  if(content.msg.length > 0){

      		  		var cc = $('.clkitm').length;

      		     $.each(content.msg, function(i,val){     
 		             //   var htmls = template.render('shoplist', {list:val}); 
 		                var htmls = trancertdata(val);
                   $('#supplierlist').append(htmls); 
                   $('.clkitm').eq(Number(i)+Number(cc)).fadeIn(); 
               });  
               page = Number(page+1);  
               $(".mBxCr").hide(); 
               $('#loading').hide();
      		  }else{ 
      		      can_show ==  false; 
      		      if(page == 1){ 
      		      	 error($('#supplierlist'),'未查找到满足条件的数据'); 
      		      	 $(".mBxCr").hide(); 
      		      }else{ 
      		        $('#loadtip').text('数据加载完毕'); 
      		      }
      		      $('#loading').hide();

      		  }

      	}else{ 
      			 can_show ==  false; 
    	       error($('#supplierlist'),content.msg); 
    	       $('#loading').hide();
      	}  
      	 
	     }, 
       error: function(content) {  
        	can_show ==  false; 
    	    error($('#supplierlist'),'店铺数据为空'); 
    	    $('#loading').hide();
	     }

     });   

}
function trancertdata(datas){
	var backdata = '';
	var tempdata = 'red';
	var tempdata2 = '营业中';
	    if(datas.opentype != 2){
	    	tempdata = '#ccc';
	    	tempdata2 = '已打烊';
	    } 
		if(datas.opentype ==3){
	    	tempdata = 'green';
	    	tempdata2 = '可预订';
	    } 
       backdata ='<li class="clkitm " data-supplierid="'+datas.id+'" style="display:none; "  > ';
      //if(datas.opentype != 2 && datas.opentype !=3){
	  //  	backdata += '<a href="#">';
	  //  }else{
	    		backdata += '<a href="'+siteurl+'/index.php?ctrl=wxsite&action=shophuishow&id='+datas.id+'">';
	 //   }
      backdata +='<img class="scrollLoading"  src="'+datas.shoplogo+'" alt="" >';
      backdata +='<h3><strong style="font-size:16px; color:#333333;">'+datas.shopname+'</strong></h3>';
	  
	
		  backdata +='<div class="address" style="height:12px; line-height:12px;margin-top:8px;color:#666666;">营业时间:'+datas.starttime+'</div> ';
		  backdata +='<div class="address" style="height:12px; line-height:12px;margin-top:8px;color:#666666;">地址:'+datas.address+'</div> ';
		
	if(datas.shopshui != ''){
	  
		  backdata +='<div class="address" style="font-size:12px;padding:0px; width:80%;">';
		  backdata +='<p  style="border:none; color:red;position:relative;">'+datas.shopshui.name+'</p>';
		  backdata +='</div>';
		
	}
	/*  
      if(datas.gzdata  != ''){
           backdata +='<div class="shanbqs"> '+datas.gzdata+' </div>';
      } */
      backdata +='</a> ';
	  
	  
	  
	  
	  
  //    backdata +=' <div style="position:absolute;position: absolute;background-color: '+tempdata+';height: 20px;width: 50px;right: 20px;font-size:1.2rem;margin-top: -45px;color: #ffffff;text-align: center;line-height: 20px;">'+tempdata2+'</div></li> ';
      return backdata;
}
$(window).scroll(function(){   //滚动获取数据 
	if(can_show == true && $(".mBxCr").is(":hidden") == true){ 
    if ($(document).height() - $(this).scrollTop() - $(this).height()<50) shopdata();   
  } 
});

</script>
<script id="shoplist" type="text/html">    
 	 <li class="clkitm <^%if(list.opentype != 2&&list.opentype !=3){%^>disabled<^%}%^>" data-supplierid="<^%=list.id%^>" style="display:none;"  > 
 <^%if(list.opentype != 2&&list.opentype !=3){%^>
 	 <a href="#">
 	<^%}else{%^>
 	   <a href="<{$siteurl}>/index.php?ctrl=wxsite&action=shopshow&id=<^%=list.id%^>">
 <^%}%^>
        <img class="scrollLoading"  src="<^%=list.shoplogo%^>" alt="" >

        <h3><strong><^%=list.shopname%^></strong></h3> 
        <div class="qisong">
                <p><^%=list.limitcost%^>&nbsp;元起送</p>
                <p>送餐费&nbsp;<^%=list.pscost%^>&nbsp;元</p> 
        </div>

        <div class="address">配送时间:<^%=list.starttime%^></div> 
        
        
         <^%if(list.gzdata != ''){%^>
        <div class="shanbqs"> <^%=list.gzdata%^> </div>
        <^%}%^>
       </a>

    </li> 

</script>
<script>
	var startX = 0, startY = 0;
 
	function touchSatrtFunc(evt) {
                try
                {
                    //evt.preventDefault(); //阻止触摸时浏览器的缩放、滚动条滚动等

                    var touch = evt.touches[0]; //获取第一个触点
                    var x = Number(touch.pageX); //页面触点X坐标
                    var y = Number(touch.pageY); //页面触点Y坐标
                    //记录触点初始位置
                    startX = x;
                    startY = y; 
                 //  var text = 'TouchStart事件触发：（' + x + ', ' + y + '）';
                 //  document.getElementById("result").innerHTML = text;
                }
                catch (e) {
                   // alert('touchSatrtFunc：' + e.message);
                }
  }
	function touchMoveFunc(evt,targetname) {
    try{
                    //evt.preventDefault(); //阻止触摸时浏览器的缩放、滚动条滚动等
                    var touch = evt.touches[0]; //获取第一个触点
                    var x = Number(touch.pageX); //页面触点X坐标
                    var y = Number(touch.pageY); //页面触点Y坐标
                    //alert($(evt).html());

                  //  var text = 'TouchMove事件触发：（' + x + ', ' + y + '）';

                    //判断滑动方向
                    if (x - startX != 0) {
                        // text += '<br/>左右滑动';
                        // -的时候为向左滑动  +  向右滑动
                        var mudi = x - startX;
                     //   text += '<br/>'+mudi;
                        var oldpostion = parseInt($('#'+targetname).css('left'));
                        var nowposition = Number(oldpostion) + Number(mudi);
                        var zongchang = parseInt($('#'+targetname).css('width'));
                     //   text += '<br/>新位置'+nowposition;
                        if(nowposition > 0){
                        	$('#'+targetname).css({left:0});  
                        }else{ 
                        	var checkchang = Number(zongchang)+Number(nowposition);
                        	if(checkchang > 0){
                          $('#'+targetname).css({left:nowposition});  
                          }else{
                          	 var dochang = 200 - Number(zongchang);
                            $('#'+targetname).css({left:dochang});   
                          }
                        }
                      
                    }
                    if (y - startY != 0) {
                      //  text += '<br/>上下滑动';
                    }

                  //  document.getElementById("result").innerHTML = text;
     }catch (e) {
                  //  alert('touchMoveFunc：' + e.message);
    }
  }
  function touchEndFunc(evt) {
                try {
                    //evt.preventDefault(); //阻止触摸时浏览器的缩放、滚动条滚动等

                 //   var text = 'TouchEnd事件触发';
                //    document.getElementById("result").innerHTML = text;
                }
                catch (e) {
                  //  alert('touchEndFunc：' + e.message);
                }
  }

	function bindEvent() {
         document.getElementById('cuisien').addEventListener('touchstart', touchSatrtFunc, false); 
         document.getElementById('cuisien').addEventListener('touchmove', function(e) { touchMoveFunc(e,'cuisien'); } , false);
         document.addEventListener('touchend', touchEndFunc, false); 
  } 
	function isTouchDevice() { 
      try {
         document.createEvent("TouchEvent"); 
         bindEvent(); //绑定事件
      }
      catch (e) { 
      }
  } 
  window.onload = isTouchDevice;
 </script>
<{/block}>
<{block name=myScrolljs}>
<script>
		var myScroll, pullDownEl, pullDownOffset,pulldowncate,
	pullUpEl, pullUpOffset,
	generatedCount = 0;

function pullDownAction () {
	/*
	setTimeout(function () {	// <-- Simulate network congestion, remove setTimeout from production!
		var el, li, i;
		el = document.getElementById('thelist');

		for (i=0; i<3; i++) {
			li = document.createElement('li');
			li.innerText = 'Generated row ' + (++generatedCount);
			el.insertBefore(li, el.childNodes[0]);
		}
		
		myScroll.refresh();		// Remember to refresh when contents are loaded (ie: on ajax completion)
	}, 1000);	// <-- Simulate network congestion, remove setTimeout from production!
	*/
}

function pullUpAction () {
	setTimeout(function () {	// <-- Simulate network congestion, remove setTimeout from production!
		if(can_show == true && $(".mBxCr").is(":hidden") == true){  
        shopdata();   
    } 
		myScroll.refresh();		// Remember to refresh when contents are loaded (ie: on ajax completion)
	}, 1000);	// <-- Simulate network congestion, remove setTimeout from production!
}

function loaded() {
	pullDownEl = document.getElementById('pullDown');
	pullDownOffset = pullDownEl.offsetHeight;
	pullUpEl = document.getElementById('pullUp');	
	pullUpOffset = pullUpEl.offsetHeight;
	
	myScroll = new iScroll('wrapper', {
		hScrollbar:false, 
		vScrollbar:false,
		useTransition: true,
		topOffset: pullDownOffset,
		onRefresh: function () {
			if (pullDownEl.className.match('loading')) {
				pullDownEl.className = '';
				pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Pull down to refresh...';
			} else if (pullUpEl.className.match('loading')) {
				pullUpEl.className = '';
				pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Pull up to load more...';
			}
		},
		onScrollMove: function () {
			if (this.y > 5 && !pullDownEl.className.match('flip')) {
				pullDownEl.className = 'flip';
				pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Release to refresh...';
				this.minScrollY = 0;
			} else if (this.y < 5 && pullDownEl.className.match('flip')) {
				pullDownEl.className = '';
				pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Pull down to refresh...';
				this.minScrollY = -pullDownOffset;
			} else if (this.y < (this.maxScrollY - 5) && !pullUpEl.className.match('flip')) {
				pullUpEl.className = 'flip';
				pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Release to refresh...';
				this.maxScrollY = this.maxScrollY;
			} else if (this.y > (this.maxScrollY + 5) && pullUpEl.className.match('flip')) {
				pullUpEl.className = '';
				pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Pull up to load more...';
				this.maxScrollY = pullUpOffset;
			}
		},
		onScrollEnd: function () {
			if (pullDownEl.className.match('flip')) {
				pullDownEl.className = 'loading';
				pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Loading...';				
				pullDownAction();	// Execute custom function (ajax call?)
			} else if (pullUpEl.className.match('flip')) {
				pullUpEl.className = 'loading';
				pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Loading...';				
				pullUpAction();	// Execute custom function (ajax call?)
			}
		}
	});
	pulldowncate = new iScroll('wrappercate', {
		hScrollbar:false, 
		vScrollbar:false,
		useTransition: true,
		topOffset: pullDownOffset
		
	});
	
	setTimeout(function () { document.getElementById('wrappercate').style.left = '0'; }, 800);
	setTimeout(function () { document.getElementById('wrapper').style.left = '0'; }, 800);
}

document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

document.addEventListener('DOMContentLoaded', function () { setTimeout(loaded, 200); }, false);


</script>

<{/block}>
<{block name=sitetitle}><{$sitename}><{/block}>
<{block name=hearnav}>
   <header   id="shopheader" style="height:42px;">
   	<div class="logo" style="display:none;"><h1 class="m-icon i-etaoshi" style="background:url(http://m2.waimairen.com/upload/goods/20140524170450380.png) center no-repeat;"> </h1></div>
   	<ul class="city box_inline" style="padding: 0px;">
	<li style="width:0px;"  class="nowcity"><em data-role="city" ></em><i class="m-icon i-caret-down"></i></li>
	<li ><div class="form-item search-box" style="height:42px; line-height:42px;" id="moui_1419388732218"><span class="m-ipt" style="font-size:18px;" data-role="addr" id="showareainfo1">闪惠商家</span></div></li>
</ul>
   	
   </header>


<{/block}>
<{block name=blockcontent}> 
<style>
#cuisien{padding:0px;}
#cuisien li{ text-align:center;width:100%;clear:both;display: block; height:40px; line-height:40px; padding:0px; margin:0px;}
.kouweixz{ width:33.3%; float:left;background:#fff; font-size:14px;  height:41px; line-height:41px; border-bottom:1px solid #d9d9d9; text-align:center; color:#0088cc; border-right:1px solid #e5e5e5;}
.kouweixzpx{ width:33.3%; float:left;background:#fff; font-size:14px;  height:41px; line-height:41px; border-bottom:1px solid #d9d9d9; text-align:center; color:#0088cc; border-right:1px solid #e5e5e5;}
.kouweixzqsj{ width:33.3%; float:left;background:#fff; font-size:14px;  height:41px; line-height:41px; border-bottom:1px solid #d9d9d9; text-align:center; color:#0088cc; border-right:1px solid #e5e5e5;}
.kwselected{width:90%; margin:0 auto;}
.kwselectedpx{width:90%; margin:0 auto;}
.kwselectedqsj{width:90%; margin:0 auto;}
.kouweiwx{background:url(<{$siteurl}>/templates/<{$tempdir}>/public/wxsite/images/kouweiBg11.png) #ffffff right center no-repeat; color:#323232; font-size:14px; font-weight:normal;}
.kouweiwxpx{background:url(<{$siteurl}>/templates/<{$tempdir}>/public/wxsite/images/kouweiBg11.png) #ffffff right center no-repeat; color:#323232; font-size:14px; font-weight:normal;}
.kouweiwxqsj{background:url(<{$siteurl}>/templates/<{$tempdir}>/public/wxsite/images/kouweiBg11.png) #ffffff right center no-repeat; color:#323232; font-size:14px; font-weight:normal;}
.kouweiokERR{background:url(<{$siteurl}>/templates/<{$tempdir}>/public/wxsite/images/kouweiseBg.png) #ffffff right center no-repeat;}
.kouweidiv{ display:none;width:33.3%;background:#ffffff; position:absolute;z-index:999; top:85px; left:0px; border:1px solid #d9d9d9; }
.kouweidivpx{ display:none;width:33.3%;background:#ffffff; position:absolute;z-index:999; top:85px; left:33.3%; border-bottom:1px solid #d9d9d9; }
#cuisienpx{padding:0px;}
#cuisienpx li{ text-align:center;width:100%;clear:both;display: block; height:40px; line-height:40px; padding:0px; margin:0px;border: 1px solid #e5e5e5; background:#fff;font-size: 1.5rem;}
.kouweidivqsj{ display:none;width:33.3%;background:#ffffff; position:absolute;z-index:999; top:85px; left:66.6%; border-bottom:1px solid #d9d9d9; }
#cuisienqsj{padding:0px;}
#cuisienqsj li{ text-align:center;width:100%;clear:both;display: block; height:40px; line-height:40px; padding:0px; margin:0px;border: 1px solid #e5e5e5; background:#fff;font-size: 1.5rem;}
#cuisienpx li.xz {
  background-color: #fe5052;
  color: #fff;
}
#cuisienpx li.xz a {
  color: #fff;
}
#cuisienqsj li.xz {
  background-color: #fe5052;
  color: #fff;
}
#cuisienqsj li.xz a {
  color: #fff;
}
</style>
 <div class="caipinglist float_top" id="ucsss" style="position:fixed;z-index:1000; height:52px;">  
    <form id="fabupaotui" method="post" action="<{ofunc type=url link="/wxsite/shophui"}>">
  <div class="header-bar" style="height:52px; background:none; border-bottom:1px solid #CACACA;">
		
		<div style="width:95%; margin:0 auto;">
			<input type="text" value="<{$search_input}>" id="search_input" name="search_input" placeholder="输入闪惠商家名称" style="width:80%; float:left; background:#EFEFEF; height:42px; line-height:42px;   border-radius:5px; margin: 0px;
    padding: 0px 0px;
    border: 0px; margin-top:5px;" />
	<input type="submit" value="搜索" id="searchbutton" style="width:18%;color:#fff; background:#fe5052;border-radius:5px;float:right; height:42px;  padding: 0px;
    border: 0px;line-height:42px;margin-top:5px; " />
		</div>
		
        </div>
</form>
    </div>



	

 <div id="wrapper" style="margin-top:52px;bottom:0px;">
	<div id="scroller">
		
		<div id="pullDown" style="display:none;">
			<span class="pullDownIcon"></span><span class="pullDownLabel">Pull down to refresh...</span>
		</div>
		
   

  <div id="result"></div>

  <div class="container" id="relist">

  	<section>

  		<ul id="supplierlist" class="branch-list">  

  			 

     </ul>

     <div class="mBxCr" style="display: hidden;"><span class="more" id="loadtip">加载更多</span></div>

    </section>
  </div>
   
   <div id="pullUp" style="display:none;">
			<span class="pullUpIcon"></span><span class="pullUpLabel">Pull up to refresh...</span>
		</div>
   
   
   
</div>
</div>
<{/block}>